package com.xzw.test.springcloud.routes;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//http://10.1.88.78:8009/java/payment/get/1

/**
 * 配置的形式也可以，在配置里面配置了一份，但是已经注释了
 */
@Configuration
@Slf4j
public class GatewayRoutes {

    @Bean
    public RouteLocator routeLocator(RouteLocatorBuilder builder) {
        log.info("-----Gateway route-----");
        return builder.routes()
                .route(r ->
                        r.path("/java/**")
                                .filters(
                                        f -> f.stripPrefix(1)
                                )
                                .uri("http://localhost:8090/helloWorld")
                                .uri("http://10.1.88.78:8001/payment/get")//提供者地址
                )
                .build();
    }
}
